package com.candy.control;

import com.candy.modal.UserLoginModal;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "SupplierLoServlet")
public class SupplierLoServlet extends HttpServlet {
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String SupplierName= request.getParameter("sName");
        String SupplierPwd= request.getParameter("sPwd");
        System.out.println("登录的用户名："+SupplierName+"，登录的密码："+SupplierPwd);
        UserLoginModal userM=new UserLoginModal();
        String strSql="select * from supplier where sid='"+SupplierName+"' and s_pwd='"+SupplierPwd+"'";
        boolean isok=userM.isLogined(strSql);
        if(isok){
            request.getSession().setAttribute("SloginedName",SupplierName);
            System.out.println("登录成功");
            request.getRequestDispatcher("supplier.jsp").forward(request,response);
        }else {
            response.sendRedirect("slogin.jsp");
        }
    }

}
